//
//  SportView.m
//  JunZeWristband
//
//  Created by Kendama on 2017/9/9.
//  Copyright © 2017年 DT. All rights reserved.
//

#import "SportView.h"

@implementation SportView

- (UIImageView *)bgImageView
{
    if(!_bgImageView)
    {
        UIView *superView = self;
        _bgImageView = [[UIImageView alloc]init];
        [superView addSubview:_bgImageView];
        _bgImageView.image = [UIImage imageNamed:@"bg_exercise"];
    }
    return _bgImageView;
}
- (UIImageView *)circleBgView
{
    if(!_circleBgView)
    {
        UIView *superView = self;
        _circleBgView = [[UIImageView alloc]init];
        [superView addSubview:_circleBgView];
        _circleBgView.image = [UIImage imageNamed:@"bg_number"];
    }
    return _circleBgView;
}
- (UIImageView *)circleView
{
    if(!_circleView)
    {
        UIView *superView = self;
        _circleView = [[UIImageView alloc]init];
        [superView addSubview:_circleView];
        _circleView.image = [UIImage imageNamed:@"gif_green"];
    }
    return _circleView;
}

- (UILabel *)stepLabel
{
    if(!_stepLabel)
    {
        UIView *superView = self;
        _stepLabel = [[UILabel alloc]init];
        [superView addSubview:_stepLabel];
        [_stepLabel setFont:[UIFont systemFontOfSize:40]];
        [_stepLabel setTextColor:[UIColor colorWithHexString:@"9AE19E"]];
        _stepLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _stepLabel;
}

- (UILabel *)titleLabel
{
    if(!_titleLabel)
    {
        UIView *superView = self;
        _titleLabel = [[UILabel alloc]init];
        [superView addSubview:_titleLabel];
        [_titleLabel setFont:[UIFont systemFontOfSize:15]];
        [_titleLabel setTextColor:[UIColor darkGrayColor]];
    }
    return _titleLabel;
}

- (UILabel *)tipLabel
{
    if(!_tipLabel)
    {
        UIView *superView = self;
        _tipLabel = [[UILabel alloc]init];
        [superView addSubview:_tipLabel];
        [_tipLabel setFont:[UIFont systemFontOfSize:15]];
        [_tipLabel setTextColor:[UIColor grayColor]];
        _tipLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _tipLabel;
}

//- (DataView *)dateView
//{
//    if(!_dateView)
//    {
//        UIView *superView = self;
//        _dateView = [[DataView alloc]init];
//        [superView addSubview:_dateView];
//        _dateView.dataLabel.textColor = [UIColor colorWithHexString:@"9AE19E"];
//    }
//    return _dateView;
//}
- (DataView *)distanceView
{
    if(!_distanceView)
    {
        UIView *superView = self;
        _distanceView = [[DataView alloc]init];
        [superView addSubview:_distanceView];
        _distanceView.dataLabel.textColor = [UIColor colorWithHexString:@"9AE19E"];

    }
    return _distanceView;
}
- (DataView *)targetView
{
    if(!_targetView)
    {
        UIView *superView = self;
        _targetView = [[DataView alloc]init];
        [superView addSubview:_targetView];
        _targetView.dataLabel.textColor = [UIColor colorWithHexString:@"9AE19E"];

    }
    return _targetView;
}
- (UIButton *)dateButton
{
    if(!_dateButton)
    {
        UIView *superView = self;
        _dateButton = [[UIButton alloc]init];
        [superView addSubview:_dateButton];
        [_dateButton setImage:[UIImage imageNamed:@"icon_date"] forState:UIControlStateNormal];
    }
    return _dateButton;
}
- (UIButton *)leftButton
{
    if(!_leftButton)
    {
        UIView *superView = self;
        _leftButton = [[UIButton alloc]init];
        [superView addSubview:_leftButton];
        [_leftButton setImage:[UIImage imageNamed:@"but_left"] forState:UIControlStateNormal];
    }
    return _leftButton;
}
- (UIButton *)rightButton
{
    if(!_rightButton)
    {
        UIView *superView = self;
        _rightButton = [[UIButton alloc]init];
        [superView addSubview:_rightButton];
        [_rightButton setImage:[UIImage imageNamed:@"but_right"] forState:UIControlStateNormal];
    }
    return _rightButton;
}



- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top);
        make.left.right.mas_equalTo(superView);
        make.height.mas_equalTo(px1920Height(1030));
    }];
    
    [self.circleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(100));
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.height.width.mas_equalTo(px1920Height(800));
    }];
    
    [self.circleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.circleBgView);
        make.height.width.mas_equalTo(px1920Height(500));
    }];
    
    [self.stepLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.circleView);
        
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.stepLabel);
        make.bottom.mas_equalTo(self.stepLabel.mas_top).with.offset(px1920Height(-20));
    }];
    
    
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.stepLabel);
        make.top.mas_equalTo(self.stepLabel.mas_bottom).with.offset(px1920Height(20));
    }];
    
    [self.dateButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(49));
        make.right.mas_equalTo(superView.mas_right).with.offset(px1080Width(-49));
    }];
    
    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.circleBgView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left);
    }];
    
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.circleBgView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right);
    }];
    
//    CGFloat padding = px1080Width(50);
//    NSMutableArray *views = [NSMutableArray array];
//    [views addObjectsFromArray:@[self.dateView,self.distanceView,self.targetView]];
//    [views mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:px1080Width(280) leadSpacing:padding tailSpacing:padding];
//    [views mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(superView.mas_bottom).with.offset(px1920Height(-300));
//        UIView *blueView = (UIView *)views[0];
//        make.height.mas_equalTo(blueView.mas_width);
//    }];
    
    [self.distanceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_bottom).with.offset(px1920Height(-550));
        make.right.mas_equalTo(superView.mas_centerX).with.offset(px1080Width(-250));
    }];
    
    [self.targetView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_bottom).with.offset(px1920Height(-550));
        make.left.mas_equalTo(superView.mas_centerX).with.offset(px1080Width(250));
    }];
    
    
    self.stepLabel.text = @"0";
    self.tipLabel.text = [NSString stringWithFormat:@"%@0%@",MyNSLocalizedString(@"消耗"),MyNSLocalizedString(@"千卡")];
    self.titleLabel.text = MyNSLocalizedString(@"今日步数");
//    self.dateView.dataLabel.text = @"47";
//    self.dateView.unitLabel.text = @"时间分钟";
    self.distanceView.dataLabel.text = @"0";
    self.targetView.dataLabel.text = @"8000";
    self.distanceView.unitLabel.text = MyNSLocalizedString(@"距离（公里）");
    self.targetView.unitLabel.text = MyNSLocalizedString(@"目标（步数）");
    
}

@end
